package structure.facade;

import org.apache.commons.io.IOUtils;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;

public class FileReader {
    public String read(String sourcePath) throws IOException {
        InputStream in = this.getClass().getClassLoader().getResourceAsStream(sourcePath);
        // InputStream in = IOUtils.toInputStream(sourcePath);
        BufferedInputStream bis = new BufferedInputStream(in);
        StringBuilder builder = new StringBuilder();
        try {
            while( bis.available() > 0 ){
                builder.append((char) bis.read());
            }
        } catch (IOException e) {
            throw new RuntimeException("文件解析出现问题");
        }
        return builder.toString();
    }
}
